home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.9 KB | 83 lines | [TEXT/CWIE] |
- // ListLoop.h
-
- #ifndef ListLoop_h
- #define ListLoop_h
-
- #ifndef ListLink_h
- #include "ListLink.h"
- #endif
- #ifndef SequenceLoop_h
- #include "SequenceLoop.h"
- #endif
- #ifndef ListOf_h
- #include "ListOf.h"
- #endif
-
- template < class Target >
- class ListLoop: private SequenceLoop<List,ListNode>
- {
- typedef ListLink<Target> LinkType;
- typedef ListOf<Target> HeadType;
- typedef ListLoop<Target> LoopType;
- typedef SequenceLoop<List,ListNode> Inherited;
-
- private:
- static const ListLink<Target> *DownCast( const ListNode *n )
- {
- return static_cast< const ListLink<Target>* >( n );
- }
-
- static const ListOf<Target>& DownCast( const List& n )
- {
- return static_cast< const ListOf<Target>& >( n );
- }
-
- public:
- ListLoop( const HeadType& h ) : Inherited( h ) {}
- ListLoop( const HeadType& h, AtStart ) : Inherited( h, atStart ) {}
- ListLoop( const HeadType& h, AtEnd ) : Inherited( h, atEnd ) {}
- ListLoop( const HeadType& h, Nowhere ) : Inherited( h, nowhere ) {}
- ListLoop( const HeadType& h, const LinkType& p ) : Inherited( h, p ) {}
- ListLoop( const HeadType& h, Before, const LinkType& p ) : Inherited( h, before, p ) {}
- ListLoop( const HeadType& h, After, const LinkType& p ) : Inherited( h, after, p ) {}
- ListLoop( const HeadType& h, BeforeStart ) : Inherited( h, beforeStart ) {}
- ListLoop( const HeadType& h, AfterEnd ) : Inherited( h, afterEnd ) {}
-
- const HeadType& Owner() const { return DownCast( Inherited::Owner() ); }
-
- Inherited::Finished;
- Inherited::Unfinished;
-
- Inherited::MoveToFinish;
- Inherited::MoveToFirst;
- Inherited::MoveToLast;
- Inherited::MoveBeforeFirst;
- Inherited::MoveAfterLast;
-
- void MoveTo( const LinkType& p ) { Inherited::MoveTo( p ); }
- void MoveBefore( const LinkType& p ) { Inherited::MoveBefore( p ); }
- void MoveAfter( const LinkType& p ) { Inherited::MoveAfter( p ); }
-
- bool operator==( const LoopType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const LoopType& r ) const { return Inherited::operator!=( r ); }
-
- bool operator==( const LinkType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const LinkType& r ) const { return Inherited::operator!=( r ); }
-
- Inherited::Null;
- const LinkType *Position() const { return DownCast( Inherited::Position() ); }
-
- const LinkType *Next() const { return DownCast( Inherited::Next() ); }
- const LinkType *Previous() const { return DownCast( Inherited::Previous() ); }
-
- Target& operator*() const { return **DownCast( Inherited::operator->() ); }
- Target *operator->() const { return &**DownCast( Inherited::operator->() ); }
-
- void operator++() { Inherited::operator++(); }
- void operator++(int) { Inherited::operator++(0); }
- void operator--() { Inherited::operator--(); }
- void operator--(int) { Inherited::operator--(0); }
- };
-
- #endif
-